package com.danco.planner.essences;

import com.danco.planner.essences.arraylists.CoursesList;
import com.danco.planner.sortings.compareby.ICompareByCoursesCount;
import com.danco.planner.sortings.compareby.ICompareByName;

public class Speaker implements ICompareByName,ICompareByCoursesCount {
	
	protected String name;
	public String getName() {
		return name;
	}
	
	protected CoursesList coursesList;
	public CoursesList getCoursesList() {
		return coursesList;
	}
	
	public Speaker(String name) {
		super();
		
		this.name = name;
		coursesList = new CoursesList();
	}

	@Override
	public String toString() {
		
		return "Speaker: " + name + ";";
	}
	public String toString(boolean withCoursesNames) {
		
		if (withCoursesNames) {
			
			StringBuilder stb = new StringBuilder(toString() + " Courses: ");
			for (Course course : coursesList) {
				stb.append(course.getName() + ", ");
			}		
			stb.deleteCharAt(stb.length()-1);
			stb.deleteCharAt(stb.length()-1);
			stb.append(';');
			
			return stb.toString();
		} else {
			
			return toString();
		}
	}

	@Override
	public Integer getCoursesCountForCompare() {
		// TODO Auto-generated method stub
		return coursesList.size();
	}
	@Override
	public String getNameForCompare() {
		// TODO Auto-generated method stub
		return name;
	}
}
